/**
 * File: AccountHolder.java
 * @author Zhiqiang Zhu
 *  Provide basic account services
 */
public class AccountHolder {

	public static double annualInterestRate;
	double balance;
	
	/**
	 * Construct a new account
	 * @param initialBalance
	 * 		Initial balance set for new account
	 */
	public AccountHolder(double initialBalance) {
		// Set member field to initial value
		balance = initialBalance;
	}

	/**
	 * Deposit an amount
	 * @param amount
	 * 		Deposit amount
	 */
	public void deposit(double amount) {
		// Add the deposit amount to the balance
		balance = balance + amount;
	}

	/**
	 * Withdraw an amount
	 * @param amount
	 * 		Withdrawal amount
	 */
	public boolean withdraw(double amount) {
		// Subtract the withdrawal amount from the balance
		if (balance - amount >= 50) {
			balance = balance - amount;
			return true;
		}
		else {
			return false;
		}
	}

	/**
	 * Calculate interest and add it to the balance
	 */
	public void monthlyInterest() {
		// Calculate interest and add it to the balance
		balance = balance + balance * (annualInterestRate / 12.0);
	}

	/**
	 * Get current balance
	 * @return
	 * 		current balance
	 */
	public double getBalance() {
		return balance;
	}
	
	/**
	 * Reset balance
	 * @param balance
	 * 		new balance amount
	 */
	public void setBalance(double balance) {
		this.balance = balance;
	}
}
